#include <cppunit/config/SourcePrefix.h>

#include "PKBStubForParentTest.h"
#include "QueryExpressionParser.h"
#include "TestQueryExpressionParser.h"

void QueryExpressionParserTest::setUp() {
	cout << "Test QueryExpressionParser setUp()\n";
}

void QueryExpressionParserTest::tearDown() {
}

// Registers the fixture into the 'registry'
CPPUNIT_TEST_SUITE_REGISTRATION( QueryExpressionParserTest );

// method to test the constructor
void QueryExpressionParserTest::testConstructor() {
	// Just to ensure it does not produce errors
	PKBStubForParentTest pkbStub;
	QueryExpressionParser queryExpParser(&pkbStub);
}

// Tests the addRelationshipEntry function
void QueryExpressionParserTest::testConvertExpressionToTree() {
	PKBStubForParentTest pkbStub;
	QueryExpressionParser queryExpParser(&pkbStub);

	// Used during testing
	TreeNode* exprRoot = NULL;
	TreeNode* parent = NULL;
	TreeNode* parent2 = NULL;
	TreeNode* leftChild = NULL;
	TreeNode* rightChild = NULL;

	// Invalid expressions
	exprRoot = queryExpParser.convertExpressionToTree(""); 
	CPPUNIT_ASSERT(NULL == exprRoot);

	exprRoot = queryExpParser.convertExpressionToTree("(x+y");
	CPPUNIT_ASSERT(NULL == exprRoot);

	exprRoot = queryExpParser.convertExpressionToTree("x+y)");
	CPPUNIT_ASSERT(NULL == exprRoot);

	exprRoot = queryExpParser.convertExpressionToTree("x+0y");
	CPPUNIT_ASSERT(NULL == exprRoot);

	// "x"
	exprRoot = queryExpParser.convertExpressionToTree("x");
	CPPUNIT_ASSERT(NULL != exprRoot);
	CPPUNIT_ASSERT_EQUAL(AST_VAR, exprRoot->getNodeType());
	CPPUNIT_ASSERT_EQUAL(0, exprRoot->getNumberOfChildren());
	CPPUNIT_ASSERT_EQUAL(1, exprRoot->getContent());

	// "x + y"
	exprRoot = queryExpParser.convertExpressionToTree("x +y");
	CPPUNIT_ASSERT(NULL != exprRoot);
	CPPUNIT_ASSERT_EQUAL(AST_PLUS, exprRoot->getNodeType());
	CPPUNIT_ASSERT_EQUAL(2, exprRoot->getNumberOfChildren());
	CPPUNIT_ASSERT_EQUAL(-1, exprRoot->getContent());
	parent = exprRoot;

	leftChild = parent->getChild().at(0); // leftChild is "x"
	rightChild = parent->getChild().at(1); // rightChild is "y"
	CPPUNIT_ASSERT_EQUAL(AST_VAR, leftChild->getNodeType());
	CPPUNIT_ASSERT_EQUAL(0, leftChild->getNumberOfChildren());
	CPPUNIT_ASSERT_EQUAL(1, leftChild->getContent());
	CPPUNIT_ASSERT_EQUAL(AST_VAR, rightChild->getNodeType());
	CPPUNIT_ASSERT_EQUAL(0, rightChild->getNumberOfChildren());
	CPPUNIT_ASSERT_EQUAL(2, rightChild->getContent());

	// "x * y + z"
	exprRoot = queryExpParser.convertExpressionToTree("x *y+ z");
	CPPUNIT_ASSERT(NULL != exprRoot);
	CPPUNIT_ASSERT_EQUAL(AST_PLUS, exprRoot->getNodeType());
	CPPUNIT_ASSERT_EQUAL(2, exprRoot->getNumberOfChildren());
	CPPUNIT_ASSERT_EQUAL(-1, exprRoot->getContent());
	parent = exprRoot;

	leftChild = parent->getChild().at(0); // leftChild is "*"
	rightChild = parent->getChild().at(1); // rightChild is "z"
	CPPUNIT_ASSERT_EQUAL(AST_TIMES, leftChild->getNodeType());
	CPPUNIT_ASSERT_EQUAL(2, leftChild->getNumberOfChildren());
	CPPUNIT_ASSERT_EQUAL(-1, leftChild->getContent());
	CPPUNIT_ASSERT_EQUAL(AST_VAR, rightChild->getNodeType());
	CPPUNIT_ASSERT_EQUAL(0, rightChild->getNumberOfChildren());
	CPPUNIT_ASSERT_EQUAL(3, rightChild->getContent());
	parent = leftChild;

	leftChild = parent->getChild().at(0); // leftChild is "x"
	rightChild = parent->getChild().at(1); // rightChild is "y"
	CPPUNIT_ASSERT_EQUAL(AST_VAR, leftChild->getNodeType());
	CPPUNIT_ASSERT_EQUAL(0, leftChild->getNumberOfChildren());
	CPPUNIT_ASSERT_EQUAL(1, leftChild->getContent());
	CPPUNIT_ASSERT_EQUAL(AST_VAR, rightChild->getNodeType());
	CPPUNIT_ASSERT_EQUAL(0, rightChild->getNumberOfChildren());
	CPPUNIT_ASSERT_EQUAL(2, rightChild->getContent());

	// "(x+y)"
	exprRoot = queryExpParser.convertExpressionToTree("x +y");
	CPPUNIT_ASSERT(NULL != exprRoot);
	CPPUNIT_ASSERT_EQUAL(AST_PLUS, exprRoot->getNodeType());
	CPPUNIT_ASSERT_EQUAL(2, exprRoot->getNumberOfChildren());
	CPPUNIT_ASSERT_EQUAL(-1, exprRoot->getContent());
	parent = exprRoot;

	leftChild = parent->getChild().at(0); // leftChild is "x"
	rightChild = parent->getChild().at(1); // rightChild is "y"
	CPPUNIT_ASSERT_EQUAL(AST_VAR, leftChild->getNodeType());
	CPPUNIT_ASSERT_EQUAL(0, leftChild->getNumberOfChildren());
	CPPUNIT_ASSERT_EQUAL(1, leftChild->getContent());
	CPPUNIT_ASSERT_EQUAL(AST_VAR, rightChild->getNodeType());
	CPPUNIT_ASSERT_EQUAL(0, rightChild->getNumberOfChildren());
	CPPUNIT_ASSERT_EQUAL(2, rightChild->getContent());

	// "x+x+y+z"
	cout << "COME HERE" << endl;
	exprRoot = queryExpParser.convertExpressionToTree("x+x+y+z+x");
	CPPUNIT_ASSERT(NULL != exprRoot);
	CPPUNIT_ASSERT_EQUAL(AST_PLUS, exprRoot->getNodeType());
	CPPUNIT_ASSERT_EQUAL(2, exprRoot->getNumberOfChildren());
	CPPUNIT_ASSERT_EQUAL(-1, exprRoot->getContent());
	parent = exprRoot;

	leftChild = parent->getChild().at(0); // leftChild is "+"
	rightChild = parent->getChild().at(1); // rightChild is "a"
	CPPUNIT_ASSERT_EQUAL(AST_PLUS, leftChild->getNodeType());
	CPPUNIT_ASSERT_EQUAL(2, leftChild->getNumberOfChildren());
	CPPUNIT_ASSERT_EQUAL(-1, leftChild->getContent());
	CPPUNIT_ASSERT_EQUAL(AST_VAR, rightChild->getNodeType());
	CPPUNIT_ASSERT_EQUAL(0, rightChild->getNumberOfChildren());
	CPPUNIT_ASSERT_EQUAL(1, rightChild->getContent());
	parent = leftChild;

	leftChild = parent->getChild().at(0); // leftChild is "+"
	rightChild = parent->getChild().at(1); // rightChild is "z"
	CPPUNIT_ASSERT_EQUAL(AST_PLUS, leftChild->getNodeType());
	CPPUNIT_ASSERT_EQUAL(2, leftChild->getNumberOfChildren());
	CPPUNIT_ASSERT_EQUAL(-1, leftChild->getContent());
	CPPUNIT_ASSERT_EQUAL(AST_VAR, rightChild->getNodeType());
	CPPUNIT_ASSERT_EQUAL(0, rightChild->getNumberOfChildren());
	CPPUNIT_ASSERT_EQUAL(3, rightChild->getContent());
	parent = leftChild;

	leftChild = parent->getChild().at(0); // leftChild is "+"
	rightChild = parent->getChild().at(1); // rightChild is "y"
	CPPUNIT_ASSERT_EQUAL(AST_PLUS, leftChild->getNodeType());
	CPPUNIT_ASSERT_EQUAL(2, leftChild->getNumberOfChildren());
	CPPUNIT_ASSERT_EQUAL(-1, leftChild->getContent());
	CPPUNIT_ASSERT_EQUAL(AST_VAR, rightChild->getNodeType());
	CPPUNIT_ASSERT_EQUAL(0, rightChild->getNumberOfChildren());
	CPPUNIT_ASSERT_EQUAL(2, rightChild->getContent());
	parent = leftChild;

	leftChild = parent->getChild().at(0); // leftChild is "x"
	rightChild = parent->getChild().at(1); // rightChild is "x"
	CPPUNIT_ASSERT_EQUAL(AST_VAR, leftChild->getNodeType());
	CPPUNIT_ASSERT_EQUAL(0, leftChild->getNumberOfChildren());
	CPPUNIT_ASSERT_EQUAL(1, leftChild->getContent());
	CPPUNIT_ASSERT_EQUAL(AST_VAR, rightChild->getNodeType());
	CPPUNIT_ASSERT_EQUAL(0, rightChild->getNumberOfChildren());
	CPPUNIT_ASSERT_EQUAL(1, rightChild->getContent());

	// "y*x*y"
	exprRoot = queryExpParser.convertExpressionToTree("y*x*y");
	CPPUNIT_ASSERT(NULL != exprRoot);
	CPPUNIT_ASSERT_EQUAL(AST_TIMES, exprRoot->getNodeType());
	CPPUNIT_ASSERT_EQUAL(2, exprRoot->getNumberOfChildren());
	CPPUNIT_ASSERT_EQUAL(-1, exprRoot->getContent());
	parent = exprRoot;

	leftChild = parent->getChild().at(0); // leftChild is "*"
	rightChild = parent->getChild().at(1); // rightChild is "y"
	CPPUNIT_ASSERT_EQUAL(AST_TIMES, leftChild->getNodeType());
	CPPUNIT_ASSERT_EQUAL(2, leftChild->getNumberOfChildren());
	CPPUNIT_ASSERT_EQUAL(-1, leftChild->getContent());
	CPPUNIT_ASSERT_EQUAL(AST_VAR, rightChild->getNodeType());
	CPPUNIT_ASSERT_EQUAL(0, rightChild->getNumberOfChildren());
	CPPUNIT_ASSERT_EQUAL(2, rightChild->getContent());
	parent = leftChild;

	leftChild = parent->getChild().at(0); // leftChild is "y"
	rightChild = parent->getChild().at(1); // rightChild is "x"
	CPPUNIT_ASSERT_EQUAL(AST_VAR, leftChild->getNodeType());
	CPPUNIT_ASSERT_EQUAL(0, leftChild->getNumberOfChildren());
	CPPUNIT_ASSERT_EQUAL(2, leftChild->getContent());
	CPPUNIT_ASSERT_EQUAL(AST_VAR, rightChild->getNodeType());
	CPPUNIT_ASSERT_EQUAL(0, rightChild->getNumberOfChildren());
	CPPUNIT_ASSERT_EQUAL(1, rightChild->getContent());

	// "x+y*x*y+z"
	exprRoot = queryExpParser.convertExpressionToTree("x+y*x*y+z");
	CPPUNIT_ASSERT(NULL != exprRoot);
	CPPUNIT_ASSERT_EQUAL(AST_PLUS, exprRoot->getNodeType());
	CPPUNIT_ASSERT_EQUAL(2, exprRoot->getNumberOfChildren());
	CPPUNIT_ASSERT_EQUAL(-1, exprRoot->getContent());
	parent = exprRoot;

	leftChild = parent->getChild().at(0); // leftChild is "+"
	rightChild = parent->getChild().at(1); // rightChild is "z"
	CPPUNIT_ASSERT_EQUAL(AST_PLUS, leftChild->getNodeType());
	CPPUNIT_ASSERT_EQUAL(2, leftChild->getNumberOfChildren());
	CPPUNIT_ASSERT_EQUAL(-1, leftChild->getContent());
	CPPUNIT_ASSERT_EQUAL(AST_VAR, rightChild->getNodeType());
	CPPUNIT_ASSERT_EQUAL(0, rightChild->getNumberOfChildren());
	CPPUNIT_ASSERT_EQUAL(3, rightChild->getContent());
	parent = leftChild;

	leftChild = parent->getChild().at(0); // leftChild is "x"
	rightChild = parent->getChild().at(1); // rightChild is "*"
	CPPUNIT_ASSERT_EQUAL(AST_VAR, leftChild->getNodeType());
	CPPUNIT_ASSERT_EQUAL(0, leftChild->getNumberOfChildren());
	CPPUNIT_ASSERT_EQUAL(1, leftChild->getContent());
	CPPUNIT_ASSERT_EQUAL(AST_TIMES, rightChild->getNodeType());
	CPPUNIT_ASSERT_EQUAL(2, rightChild->getNumberOfChildren());
	CPPUNIT_ASSERT_EQUAL(-1, rightChild->getContent());
	parent = rightChild;

	leftChild = parent->getChild().at(0); // leftChild is "*"
	rightChild = parent->getChild().at(1); // rightChild is "y"
	CPPUNIT_ASSERT_EQUAL(AST_TIMES, leftChild->getNodeType());
	CPPUNIT_ASSERT_EQUAL(2, leftChild->getNumberOfChildren());
	CPPUNIT_ASSERT_EQUAL(-1, leftChild->getContent());
	CPPUNIT_ASSERT_EQUAL(AST_VAR, rightChild->getNodeType());
	CPPUNIT_ASSERT_EQUAL(0, rightChild->getNumberOfChildren());
	CPPUNIT_ASSERT_EQUAL(2, rightChild->getContent());
	parent = leftChild;

	leftChild = parent->getChild().at(0); // leftChild is "y"
	rightChild = parent->getChild().at(1); // rightChild is "x"
	CPPUNIT_ASSERT_EQUAL(AST_VAR, leftChild->getNodeType());
	CPPUNIT_ASSERT_EQUAL(0, leftChild->getNumberOfChildren());
	CPPUNIT_ASSERT_EQUAL(2, leftChild->getContent());
	CPPUNIT_ASSERT_EQUAL(AST_VAR, rightChild->getNodeType());
	CPPUNIT_ASSERT_EQUAL(0, rightChild->getNumberOfChildren());
	CPPUNIT_ASSERT_EQUAL(1, rightChild->getContent());

	// "((x+y)*z+y)"
	exprRoot = queryExpParser.convertExpressionToTree("((x+y)*z+y)");
	CPPUNIT_ASSERT(NULL != exprRoot);
	CPPUNIT_ASSERT_EQUAL(AST_PLUS, exprRoot->getNodeType());
	CPPUNIT_ASSERT_EQUAL(2, exprRoot->getNumberOfChildren());
	CPPUNIT_ASSERT_EQUAL(-1, exprRoot->getContent());
	parent = exprRoot;

	leftChild = parent->getChild().at(0); // leftChild is "*"
	rightChild = parent->getChild().at(1); // rightChild is "y"
	CPPUNIT_ASSERT_EQUAL(AST_TIMES, leftChild->getNodeType());
	CPPUNIT_ASSERT_EQUAL(2, leftChild->getNumberOfChildren());
	CPPUNIT_ASSERT_EQUAL(-1, leftChild->getContent());
	CPPUNIT_ASSERT_EQUAL(AST_VAR, rightChild->getNodeType());
	CPPUNIT_ASSERT_EQUAL(0, rightChild->getNumberOfChildren());
	CPPUNIT_ASSERT_EQUAL(2, rightChild->getContent());
	parent = leftChild;

	leftChild = parent->getChild().at(0); // leftChild is "+"
	rightChild = parent->getChild().at(1); // rightChild is "z"
	CPPUNIT_ASSERT_EQUAL(AST_PLUS, leftChild->getNodeType());
	CPPUNIT_ASSERT_EQUAL(2, leftChild->getNumberOfChildren());
	CPPUNIT_ASSERT_EQUAL(-1, leftChild->getContent());
	CPPUNIT_ASSERT_EQUAL(AST_VAR, rightChild->getNodeType());
	CPPUNIT_ASSERT_EQUAL(0, rightChild->getNumberOfChildren());
	CPPUNIT_ASSERT_EQUAL(3, rightChild->getContent());
	parent = leftChild;

	leftChild = parent->getChild().at(0); // leftChild is "x"
	rightChild = parent->getChild().at(1); // rightChild is "y"
	CPPUNIT_ASSERT_EQUAL(AST_VAR, leftChild->getNodeType());
	CPPUNIT_ASSERT_EQUAL(0, leftChild->getNumberOfChildren());
	CPPUNIT_ASSERT_EQUAL(1, leftChild->getContent());
	CPPUNIT_ASSERT_EQUAL(AST_VAR, rightChild->getNodeType());
	CPPUNIT_ASSERT_EQUAL(0, rightChild->getNumberOfChildren());
	CPPUNIT_ASSERT_EQUAL(2, rightChild->getContent());

	// "(1+2)*3-2*3"
	exprRoot = queryExpParser.convertExpressionToTree("(1+2)*3-2*3");
	CPPUNIT_ASSERT(NULL != exprRoot);
	CPPUNIT_ASSERT_EQUAL(AST_MINUS, exprRoot->getNodeType());
	CPPUNIT_ASSERT_EQUAL(2, exprRoot->getNumberOfChildren());
	CPPUNIT_ASSERT_EQUAL(-1, exprRoot->getContent());
	parent = exprRoot;

	leftChild = parent->getChild().at(0); // leftChild is "*"
	rightChild = parent->getChild().at(1); // rightChild is "*"
	CPPUNIT_ASSERT_EQUAL(AST_TIMES, leftChild->getNodeType());
	CPPUNIT_ASSERT_EQUAL(2, leftChild->getNumberOfChildren());
	CPPUNIT_ASSERT_EQUAL(-1, leftChild->getContent());
	CPPUNIT_ASSERT_EQUAL(AST_TIMES, rightChild->getNodeType());
	CPPUNIT_ASSERT_EQUAL(2, rightChild->getNumberOfChildren());
	CPPUNIT_ASSERT_EQUAL(-1, rightChild->getContent());
	parent = leftChild;
	parent2 = rightChild;

	leftChild = parent->getChild().at(0); // leftChild is "+"
	rightChild = parent->getChild().at(1); // rightChild is "3"
	CPPUNIT_ASSERT_EQUAL(AST_PLUS, leftChild->getNodeType());
	CPPUNIT_ASSERT_EQUAL(2, leftChild->getNumberOfChildren());
	CPPUNIT_ASSERT_EQUAL(-1, leftChild->getContent());
	CPPUNIT_ASSERT_EQUAL(AST_CONST, rightChild->getNodeType());
	CPPUNIT_ASSERT_EQUAL(0, rightChild->getNumberOfChildren());
	CPPUNIT_ASSERT_EQUAL(3, rightChild->getContent());
	parent = leftChild;

	leftChild = parent2->getChild().at(0); // leftChild is "2"
	rightChild = parent2->getChild().at(1); // rightChild is "3"
	CPPUNIT_ASSERT_EQUAL(AST_CONST, leftChild->getNodeType());
	CPPUNIT_ASSERT_EQUAL(0, leftChild->getNumberOfChildren());
	CPPUNIT_ASSERT_EQUAL(2, leftChild->getContent());
	CPPUNIT_ASSERT_EQUAL(AST_CONST, rightChild->getNodeType());
	CPPUNIT_ASSERT_EQUAL(0, rightChild->getNumberOfChildren());
	CPPUNIT_ASSERT_EQUAL(3, rightChild->getContent());

	leftChild = parent->getChild().at(0); // leftChild is "1"
	rightChild = parent->getChild().at(1); // rightChild is "2"
	CPPUNIT_ASSERT_EQUAL(AST_CONST, leftChild->getNodeType());
	CPPUNIT_ASSERT_EQUAL(0, leftChild->getNumberOfChildren());
	CPPUNIT_ASSERT_EQUAL(1, leftChild->getContent());
	CPPUNIT_ASSERT_EQUAL(AST_CONST, rightChild->getNodeType());
	CPPUNIT_ASSERT_EQUAL(0, rightChild->getNumberOfChildren());
	CPPUNIT_ASSERT_EQUAL(2, rightChild->getContent());

	// "0+1+2*3+4"
	cout << "COME HERE 2" << endl;
	exprRoot = queryExpParser.convertExpressionToTree("0+1+2*3+4");
	CPPUNIT_ASSERT(NULL != exprRoot);
	CPPUNIT_ASSERT_EQUAL(AST_PLUS, exprRoot->getNodeType());
	CPPUNIT_ASSERT_EQUAL(2, exprRoot->getNumberOfChildren());
	CPPUNIT_ASSERT_EQUAL(-1, exprRoot->getContent());
	parent = exprRoot;

	leftChild = parent->getChild().at(0); // leftChild is "+"
	rightChild = parent->getChild().at(1); // rightChild is "4"
	CPPUNIT_ASSERT_EQUAL(AST_PLUS, leftChild->getNodeType());
	CPPUNIT_ASSERT_EQUAL(2, leftChild->getNumberOfChildren());
	CPPUNIT_ASSERT_EQUAL(-1, leftChild->getContent());
	CPPUNIT_ASSERT_EQUAL(AST_CONST, rightChild->getNodeType());
	CPPUNIT_ASSERT_EQUAL(0, rightChild->getNumberOfChildren());
	CPPUNIT_ASSERT_EQUAL(4, rightChild->getContent());
	parent = leftChild;

	leftChild = parent->getChild().at(0); // leftChild is "+"
	rightChild = parent->getChild().at(1); // rightChild is "*"
	CPPUNIT_ASSERT_EQUAL(AST_PLUS, leftChild->getNodeType());
	CPPUNIT_ASSERT_EQUAL(2, leftChild->getNumberOfChildren());
	CPPUNIT_ASSERT_EQUAL(-1, leftChild->getContent());
	CPPUNIT_ASSERT_EQUAL(AST_TIMES, rightChild->getNodeType());
	CPPUNIT_ASSERT_EQUAL(2, rightChild->getNumberOfChildren());
	CPPUNIT_ASSERT_EQUAL(-1, rightChild->getContent());
	parent = leftChild;
	parent2 = rightChild;

	leftChild = parent->getChild().at(0); // leftChild is "0"
	rightChild = parent->getChild().at(1); // rightChild is "1"
	CPPUNIT_ASSERT_EQUAL(AST_CONST, leftChild->getNodeType());
	CPPUNIT_ASSERT_EQUAL(0, leftChild->getNumberOfChildren());
	CPPUNIT_ASSERT_EQUAL(0, leftChild->getContent());
	CPPUNIT_ASSERT_EQUAL(AST_CONST, rightChild->getNodeType());
	CPPUNIT_ASSERT_EQUAL(0, rightChild->getNumberOfChildren());
	CPPUNIT_ASSERT_EQUAL(1, rightChild->getContent());

	leftChild = parent2->getChild().at(0); // leftChild is "2"
	rightChild = parent2->getChild().at(1); // rightChild is "3"
	CPPUNIT_ASSERT_EQUAL(AST_CONST, leftChild->getNodeType());
	CPPUNIT_ASSERT_EQUAL(0, leftChild->getNumberOfChildren());
	CPPUNIT_ASSERT_EQUAL(2, leftChild->getContent());
	CPPUNIT_ASSERT_EQUAL(AST_CONST, rightChild->getNodeType());
	CPPUNIT_ASSERT_EQUAL(0, rightChild->getNumberOfChildren());
	CPPUNIT_ASSERT_EQUAL(3, rightChild->getContent());

	// "1+2+3*(x+y*z*(4*5+6)-z)*7-8"
	cout << "COME HERE 3" << endl;
	exprRoot = queryExpParser.convertExpressionToTree("1+2+3*(x+y*z*(4*5+6)-z)*7-8");
	CPPUNIT_ASSERT(NULL != exprRoot);
	CPPUNIT_ASSERT_EQUAL(AST_MINUS, exprRoot->getNodeType());
	CPPUNIT_ASSERT_EQUAL(2, exprRoot->getNumberOfChildren());
	CPPUNIT_ASSERT_EQUAL(-1, exprRoot->getContent());
	parent = exprRoot;

	leftChild = parent->getChild().at(0); // leftChild is "+"
	rightChild = parent->getChild().at(1); // rightChild is "8"
	CPPUNIT_ASSERT_EQUAL(AST_PLUS, leftChild->getNodeType());
	CPPUNIT_ASSERT_EQUAL(2, leftChild->getNumberOfChildren());
	CPPUNIT_ASSERT_EQUAL(-1, leftChild->getContent());
	CPPUNIT_ASSERT_EQUAL(AST_CONST, rightChild->getNodeType());
	CPPUNIT_ASSERT_EQUAL(0, rightChild->getNumberOfChildren());
	CPPUNIT_ASSERT_EQUAL(8, rightChild->getContent());
	parent = leftChild;

	leftChild = parent->getChild().at(0); // leftChild is "+"
	rightChild = parent->getChild().at(1); // rightChild is "*"
	CPPUNIT_ASSERT_EQUAL(AST_PLUS, leftChild->getNodeType());
	CPPUNIT_ASSERT_EQUAL(2, leftChild->getNumberOfChildren());
	CPPUNIT_ASSERT_EQUAL(-1, leftChild->getContent());
	CPPUNIT_ASSERT_EQUAL(AST_TIMES, rightChild->getNodeType());
	CPPUNIT_ASSERT_EQUAL(2, rightChild->getNumberOfChildren());
	CPPUNIT_ASSERT_EQUAL(-1, rightChild->getContent());
	parent = leftChild;
	parent2 = rightChild;

	leftChild = parent->getChild().at(0); // leftChild is "1"
	rightChild = parent->getChild().at(1); // rightChild is "2"
	CPPUNIT_ASSERT_EQUAL(AST_CONST, leftChild->getNodeType());
	CPPUNIT_ASSERT_EQUAL(0, leftChild->getNumberOfChildren());
	CPPUNIT_ASSERT_EQUAL(1, leftChild->getContent());
	CPPUNIT_ASSERT_EQUAL(AST_CONST, rightChild->getNodeType());
	CPPUNIT_ASSERT_EQUAL(0, rightChild->getNumberOfChildren());
	CPPUNIT_ASSERT_EQUAL(2, rightChild->getContent());

	leftChild = parent2->getChild().at(0); // leftChild is "*"
	rightChild = parent2->getChild().at(1); // rightChild is "7"
	CPPUNIT_ASSERT_EQUAL(AST_TIMES, leftChild->getNodeType());
	CPPUNIT_ASSERT_EQUAL(2, leftChild->getNumberOfChildren());
	CPPUNIT_ASSERT_EQUAL(-1, leftChild->getContent());
	CPPUNIT_ASSERT_EQUAL(AST_CONST, rightChild->getNodeType());
	CPPUNIT_ASSERT_EQUAL(0, rightChild->getNumberOfChildren());
	CPPUNIT_ASSERT_EQUAL(7, rightChild->getContent());
	parent = leftChild;

	leftChild = parent->getChild().at(0); // leftChild is "3"
	rightChild = parent->getChild().at(1); // rightChild is "-"
	CPPUNIT_ASSERT_EQUAL(AST_CONST, leftChild->getNodeType());
	CPPUNIT_ASSERT_EQUAL(0, leftChild->getNumberOfChildren());
	CPPUNIT_ASSERT_EQUAL(3, leftChild->getContent());
	CPPUNIT_ASSERT_EQUAL(AST_MINUS, rightChild->getNodeType());
	CPPUNIT_ASSERT_EQUAL(2, rightChild->getNumberOfChildren());
	CPPUNIT_ASSERT_EQUAL(-1, rightChild->getContent());
	parent = rightChild;

	leftChild = parent->getChild().at(0); // leftChild is "+"
	rightChild = parent->getChild().at(1); // rightChild is "z"
	CPPUNIT_ASSERT_EQUAL(AST_PLUS, leftChild->getNodeType());
	CPPUNIT_ASSERT_EQUAL(2, leftChild->getNumberOfChildren());
	CPPUNIT_ASSERT_EQUAL(-1, leftChild->getContent());
	CPPUNIT_ASSERT_EQUAL(AST_VAR, rightChild->getNodeType());
	CPPUNIT_ASSERT_EQUAL(0, rightChild->getNumberOfChildren());
	CPPUNIT_ASSERT_EQUAL(3, rightChild->getContent());
	parent = leftChild;

	leftChild = parent->getChild().at(0); // leftChild is "x"
	rightChild = parent->getChild().at(1); // rightChild is "*"
	CPPUNIT_ASSERT_EQUAL(AST_VAR, leftChild->getNodeType());
	CPPUNIT_ASSERT_EQUAL(0, leftChild->getNumberOfChildren());
	CPPUNIT_ASSERT_EQUAL(1, leftChild->getContent());
	CPPUNIT_ASSERT_EQUAL(AST_TIMES, rightChild->getNodeType());
	CPPUNIT_ASSERT_EQUAL(2, rightChild->getNumberOfChildren());
	CPPUNIT_ASSERT_EQUAL(-1, rightChild->getContent());
	parent = rightChild;

	leftChild = parent->getChild().at(0); // leftChild is "*"
	rightChild = parent->getChild().at(1); // rightChild is "+"
	CPPUNIT_ASSERT_EQUAL(AST_TIMES, leftChild->getNodeType());
	CPPUNIT_ASSERT_EQUAL(2, leftChild->getNumberOfChildren());
	CPPUNIT_ASSERT_EQUAL(-1, leftChild->getContent());
	CPPUNIT_ASSERT_EQUAL(AST_PLUS, rightChild->getNodeType());
	CPPUNIT_ASSERT_EQUAL(2, rightChild->getNumberOfChildren());
	CPPUNIT_ASSERT_EQUAL(-1, rightChild->getContent());
	parent = leftChild;
	parent2 = rightChild;

	leftChild = parent->getChild().at(0); // leftChild is "y"
	rightChild = parent->getChild().at(1); // rightChild is "z"
	CPPUNIT_ASSERT_EQUAL(AST_VAR, leftChild->getNodeType());
	CPPUNIT_ASSERT_EQUAL(0, leftChild->getNumberOfChildren());
	CPPUNIT_ASSERT_EQUAL(2, leftChild->getContent());
	CPPUNIT_ASSERT_EQUAL(AST_VAR, rightChild->getNodeType());
	CPPUNIT_ASSERT_EQUAL(0, rightChild->getNumberOfChildren());
	CPPUNIT_ASSERT_EQUAL(3, rightChild->getContent());

	leftChild = parent2->getChild().at(0); // leftChild is "*"
	rightChild = parent2->getChild().at(1); // rightChild is "6"
	CPPUNIT_ASSERT_EQUAL(AST_TIMES, leftChild->getNodeType());
	CPPUNIT_ASSERT_EQUAL(2, leftChild->getNumberOfChildren());
	CPPUNIT_ASSERT_EQUAL(-1, leftChild->getContent());
	CPPUNIT_ASSERT_EQUAL(AST_CONST, rightChild->getNodeType());
	CPPUNIT_ASSERT_EQUAL(0, rightChild->getNumberOfChildren());
	CPPUNIT_ASSERT_EQUAL(6, rightChild->getContent());
	parent = leftChild;

	leftChild = parent->getChild().at(0); // leftChild is "4"
	rightChild = parent->getChild().at(1); // rightChild is "5"
	CPPUNIT_ASSERT_EQUAL(AST_CONST, leftChild->getNodeType());
	CPPUNIT_ASSERT_EQUAL(0, leftChild->getNumberOfChildren());
	CPPUNIT_ASSERT_EQUAL(4, leftChild->getContent());
	CPPUNIT_ASSERT_EQUAL(AST_CONST, rightChild->getNodeType());
	CPPUNIT_ASSERT_EQUAL(0, rightChild->getNumberOfChildren());
	CPPUNIT_ASSERT_EQUAL(5, rightChild->getContent());

	// z * 2 + 7 * (a + 3 * (2 - y))
	cout << "COME HERE 3" << endl;
	exprRoot = queryExpParser.convertExpressionToTree("z * 2 + 7 * (a + 3 * (2 - y))");
	CPPUNIT_ASSERT(NULL != exprRoot);
}